<template>
  <el-main>
    <el-table :data="salaryList">
      <el-table-column prop="year" label="年" width="120" align="center"></el-table-column>
      <el-table-column prop="month" label="月" width="120" align="center"></el-table-column>
      <el-table-column prop="basicSalary" label="底薪" width="120" align="center"></el-table-column>
      <el-table-column prop="percentage" label="提成" width="120" align="center"></el-table-column>
      <el-table-column prop="subsidy" label="补助" width="220" align="center"></el-table-column>
    </el-table>
  </el-main>
</template>

<script>
import { postRequestByParams } from "../utils/api";

export default {
  data() {
    return {
      salaryList: [],
      number: "",
      username: ""
    };
  },
  methods: {
    getMonthSalary: function() {
      var _this = this;
      postRequestByParams("/salary/employee-salary", {
        number: _this.number
      }).then(resp => {
        if (resp.status == 200) {
          var json = resp.data;
          _this.salaryList = json;
        }
      });
    },
    getAllInformation: function() {
      var _this = this;
      postRequestByParams("/account/get-number", {
        username: _this.username
      }).then(resp => {
        if (resp.status == 200) {
          var json = resp.data;
          if (json.message == "success") {
            _this.number = json.data;
            _this.getMonthSalary();
          } else {
            this.$alert("请绑定工号", "警告！", {
              confirmButtonText: "确定"
            });
          }
        }
      });
    }
  },
  mounted() {
    this.username = sessionStorage.getItem("username");
    this.getAllInformation();
  }
};
</script>
    
<style>
.away-from {
  margin-left: 70px;
  font-family: "Avenir";
  font-weight: bolder;
}
</style>